package com.yyhn.guilimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;


import java.io.IOException;

@Configuration
public class MyRedissonConfig {
    //所有对redission的使用都是通过RedissonClient对象
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redission() throws IOException {
        //1.创建一个配置类Config
        Config config = new Config();
        //根config自定使用单节点模式
        // setAddress("118.31.106.253:6379");指定地址
        config.useSingleServer().setAddress("redis://118.31.106.253:6379");
        //设置密码
        config.useSingleServer().setPassword("123456");
        //2.根据Config创建出RedissconClient实例
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }




}
